package ar.edu.unq.leezsi.html;

import javax.servlet.http.HttpServletResponse;

import ar.edu.unq.leezsi.utils.ResponseWriter;

public abstract class OpenCloseComponent<T> extends Component<T> {

	@Override
	protected void renderOn(HttpServletResponse response) {
		ResponseWriter responseWriter = new ResponseWriter(response);
		this.configureResponse(responseWriter);
		this.doOnBeforeRenderer();
		responseWriter.write("<").write(this.tag()).write(" ")
				.write(this.attributes()).write(">");
		for (Component<?> child : this.children) {
			child.renderOn(responseWriter.getResponse());
		}
		responseWriter.write(this.getModel().toString());
		responseWriter.write("</").write(this.tag()).write(">\n");
		this.onAfterRenderer();
	}

}
